#ifdef __APPLE__
    #include <SDL/SDL.h>
    #include "SDL/SDL_opengl.h"
#else
    #include <SDL/SDL.h>
    #include <GL/gl.h>
    #include <GL/glu.h>
    #include <GL/glext.h>
#endif
#include <iostream>
#include <string>
#include <math.h>
#include "BM_light.h"

using namespace std;

// Declare our temporary lightning arrays
// Ambient: R - G - B - A (I am not sure about the Alpha, but the first three make up RGB)
// Position: X - Y - Z - the last one tells OpenGL the coordinates (x,y,z/r,g,b) are the position of the light source
GLfloat lArray[]  = { 0.0f,  0.0f,  0.0f, 0.0f};

void BMLight::enableLightning(GLenum light)
{
    // Enable Lighting
    glEnable(GL_LIGHTING);
    glEnable(light);
}

void BMLight::disableLightning(GLenum light)
{
    // Disable Lighting
    glDisable(GL_LIGHTING);
    glDisable(light);
}

void BMLight::createLight(GLenum light, GLenum light_kind, float r, float g, float b, float a, Light_Struct * light_s)
{
    light_s->param[0] = (float)r;
    light_s->param[1] = (float)g;
    light_s->param[2] = (float)b;
    light_s->param[3] = (float)a;

    light_s->light_kind = light_kind;
    light_s->light = light;
}

void BMLight::createPositionLight(GLenum light, float x, float y, float z, float gl, Light_Struct * light_s)
{
    light_s->param[0] = (float)x;
    light_s->param[1] = (float)y;
    light_s->param[2] = (float)z;
    light_s->param[3] = (float)gl;

    //light_s->param = lArray;
    light_s->light_kind = GL_POSITION;
    light_s->light = light;
}

void BMLight::renderLight(Light_Struct * light)
{
    glLightfv(light->light, light->light_kind, light->param);

    //glLightfv(light, light_kind, param);
}

